package com.ln.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.util.WebUtils;

import com.ln.pojo.impl.UserPOJO;


public abstract class BaseController implements IBaseController {
	
	/**
	 * GET登录用户Id
	 * @param request
	 * @return
	 */
	public int getLoginUserId(HttpServletRequest request) {
		UserPOJO LOGIN_USER = getLoginUser(request);
		return (LOGIN_USER != null)?LOGIN_USER.getId():-1;
	}
	
	/**
	 * 获得登录用户OBJ
	 * @param request
	 * @return
	 */
	public UserPOJO getLoginUser(HttpServletRequest request) {
		UserPOJO LOGIN_USER = (UserPOJO)WebUtils.getSessionAttribute(request, "LOGIN_USER");
		return (LOGIN_USER != null)?LOGIN_USER:null;
	}
}
